﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace StudentApartMentManage
{
    public partial class StuInfoSeek : Form
    {
        public StuInfoSeek()
        {
            InitializeComponent();
        }

        private void StuInfoSeek_Load(object sender, EventArgs e)
        {
            dataGridView1.DataSource = DataShow.show("select 学号,姓名,性别,学院,专业,班级,民族 from 学生信息表");
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Trim().Length == 0 && textBox2.Text.Trim().Length == 0 && textBox3.Text.Trim().Length == 0 && textBox4.Text.Trim().Length == 0 && textBox5.Text.Trim().Length == 0 && textBox6.Text.Trim().Length == 0 && textBox7.Text.Trim().Length == 0)
            {
                MessageBox.Show("所有条件不能为空!");
                return;
            }
            try
            {
                string sql = string.Format("select 学号,姓名,性别,学院,专业,班级,民族 from 学生信息表 where 学号 like '{0}%' and 姓名 like '{1}%' and 性别 like '{2}%' and 学院 like '{3}%' and 专业 like '{4}%' and 班级 like '{5}%' and 民族 like  '{6}%' ", textBox1.Text.Trim(), textBox2.Text.Trim(), textBox3.Text.Trim(), textBox4.Text.Trim(), textBox5.Text.Trim(), textBox6.Text.Trim(), textBox7.Text.Trim());
                dataGridView1.DataSource = DataShow.show(sql);
                MessageBox.Show("查询成功!");
            }
            catch (Exception ex)
            {
                MessageBox.Show("查询失败!");
                return;
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("你确定要重置查询条件吗?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                textBox1.Clear();
                textBox2.Clear();
                textBox3.Clear();
                textBox4.Clear();
                textBox5.Clear();
                textBox6.Clear();
                textBox7.Clear();
               
            }
        }
    }
}
